package cn.bcsp.controller;

import cn.bcsp.pojo.User;
import cn.bcsp.service.userService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Description;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.management.Descriptor;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

/**
 * @Description: TODO
 * @author: MengJiaLin
 * @date: 2021年08月16日 上午11:29
 */
@Controller
//错误11
@Api(description = "登录接口")
public class userController {
    @Resource
    private cn.bcsp.service.userService userService;

    @RequestMapping("/login")
    @ApiOperation(value = "登录", httpMethod = "POST", produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String, Object> login(@RequestParam("username") String username, @RequestParam("password") String password, HttpSession session) {
        Map<String, Object> map = new HashMap<>();
        User login = userService.login(username, password);
        if (login == null) {
            map.put("logingg", "no");
        } else {
            map.put("logingg", "ok");
            System.out.println("1111111111111111111111111111");
        }
        return map;
		
    }


    @RequestMapping("/tologin")
    public String aa() {
        return "login";
    }

}